﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using System.Data;
using System.Collections;

namespace SavoryDL
{
    public class Savory_ParameterList : ArrayList
    {
        //public ArrayList parameterCollection = new ArrayList();

        /// <summary>   
        /// AddParameter method Adds Parameter to Collection of parameters 
        /// </summary>
        /// <param name="p_name">Name of parameter</param>
        /// <param name="p_value">Value of parameter</param>
        /// <param name="p_dataType">Data type of parameter</param>
        /// <param name="p_size">Size</param>
        /// <param name="p_direction">Parameter Direction Default:ParameterDirection.Input</param>
        public void AddParameter(string p_name, object p_value, SqlDbType p_dataType, int p_size, ParameterDirection p_direction)
        {
            SqlParameter tempParam = new SqlParameter(p_name, p_dataType);
            if (p_size != 0)
            {
                tempParam.Size = p_size;
            }
            tempParam.Direction = p_direction;
            if (p_value != null)
            {
                tempParam.Value = p_value;
            }
            this.Add(tempParam);
        }
        /// <summary>
        /// AddStringParameter method Adds String Parameter to Collection of parameters 
        /// </summary>
        /// <param name="p_name">Name of parameter</param>
        /// <param name="p_value">Value of parameter</param>
        /// <param name="p_direction">Parameter Direction Default:ParameterDirection.Input</param>
        public void AddStringParameter(string p_name, string p_value, ParameterDirection p_direction)
        {
            AddParameter(p_name, p_value, SqlDbType.VarChar, p_value.Length, p_direction);
        }
        /// <summary>
        /// AddStringParameter method Adds String Parameter to Collection of parameters 
        /// </summary>
        /// <param name="p_name">Name of parameter</param>
        /// <param name="p_value">Value of parameter</param>

        public void AddStringParameter(string p_name, string p_value)
        {
            AddParameter(p_name, p_value, SqlDbType.VarChar, p_value.Length, ParameterDirection.Input);
        }
        /// <summary>
        /// AddIntParameter method Adds integer Parameter to Collection of parameters 
        /// </summary>
        /// <param name="p_name">Name of parameter</param>
        /// <param name="p_value">Value of parameter</param>
        /// <param name="p_direction">Parameter Direction Default:ParameterDirection.Input</param>
        public void AddIntParameter(string p_name, int p_value, ParameterDirection p_direction)
        {
            AddParameter(p_name, p_value, SqlDbType.Int, 9, p_direction);
        }

        /// <summary>
        /// AddIntParameter method Adds integer Parameter to Collection of parameters 
        /// </summary>
        /// <param name="p_name">Name of parameter</param>
        /// <param name="p_value">Value of parameter</param>
        public void AddIntParameter(string p_name, int p_value)
        {
            AddParameter(p_name, p_value, SqlDbType.Int, 9, ParameterDirection.Input);
        }
        /// <summary>
        /// AddfloatParameter method Adds float Parameter to Collection of parameters 
        /// </summary>
        /// <param name="p_name">Name of parameter</param>
        /// <param name="p_value">Value of parameter</param>
        public void AddFloatParameter(string p_name, float p_value)
        {
            AddParameter(p_name, p_value, SqlDbType.Float, 9, ParameterDirection.Input);
        }

        /// <summary>
        /// AddDateTimeParameter method Adds DateTime Parameter to Collection of parameters 
        /// </summary>
        /// <param name="p_name">Name of parameter</param>
        /// <param name="p_value">Value of parameter</param>
        /// <param name="p_direction">Parameter Direction Default:ParameterDirection.Input</param>
        public void AddDateTimeParameter(string p_name, DateTime p_value, ParameterDirection p_direction)
        {
            AddParameter(p_name, p_value, SqlDbType.DateTime, 0, p_direction);
        }
        /// <summary>
        /// AddDateTimeParameter method Adds DateTime Parameter to Collection of parameters 
        /// </summary> 
        /// <param name="p_name">Name of parameter</param>
        /// <param name="p_value">Value of parameter</param>
        public void AddDateTimeParameter(string p_name, DateTime p_value)
        {
            AddParameter(p_name, p_value, SqlDbType.DateTime, 0, ParameterDirection.Input);
        }
        /// <summary>
        /// AddSmallDateTimeParameter method Adds Small DateTime Parameter to Collection of parameters 
        /// </summary> 
        /// <param name="p_name">Name of parameter</param>
        /// <param name="p_value">Value of parameter</param>
        /// <param name="p_direction">Parameter Direction Default:ParameterDirection.Input</param>
        public void AddSmallDateTimeParameter(string p_name, DateTime p_value, ParameterDirection p_direction)
        {
            AddParameter(p_name, p_value, SqlDbType.SmallDateTime, 0, p_direction);
        }
        /// <summary>
        /// AddSmallDateTimeParameter method Adds SmallDateTime Parameter to Collection of parameters 
        /// </summary>
        /// <param name="p_name">Name of parameter</param>
        /// <param name="p_value">Value of parameter</param>  
        public void AddSmallDateTimeParameter(string p_name, DateTime p_value)
        {
            AddParameter(p_name, p_value, SqlDbType.SmallDateTime, 0, ParameterDirection.Input);
        }
        /// <summary>
        /// AddTextParameter method Adds Text Parameter to Collection of parameters 
        /// </summary>
        /// <param name="p_dataType">Data type of parameter</param>               
        /// <param name="p_name">Name of parameter</param>
        /// <param name="p_value">Value of parameter</param>
        /// <param name="p_size">Size</param> 
        /// <param name="p_direction">Parameter Direction Default:ParameterDirection.Input</param>
        public void AddTextParameter(string p_name, string p_value, int p_size, ParameterDirection p_direction)
        {
            AddParameter(p_name, p_value, SqlDbType.Text, p_size, p_direction);
        }
        /// <summary>
        /// AddTextParameter method Adds Text Parameter to Collection of parameters 
        /// </summary>
        /// <param name="p_name">Name of parameter</param>
        /// <param name="p_value">Value of parameter</param>
        public void AddTextParameter(string p_name, string p_value)
        {
            AddParameter(p_name, p_value, SqlDbType.Text, p_value.Length, ParameterDirection.Input);
        }

        /// <summary>
        /// AddBooleanTimeParameter method Adds Boolean Parameter to Collection of parameters 
        /// </summary> 
        /// <param name="p_name">Name of parameter</param>
        /// <param name="p_value">Value of parameter</param>
        /// <param name="p_direction">Parameter Direction Default:ParameterDirection.Input</param>
        public void AddBooleanTimeParameter(string p_name, bool p_value, ParameterDirection p_direction)
        {
            AddParameter(p_name, p_value, SqlDbType.Bit, 1, p_direction);

        }
        /// <summary>
        /// AddBooleanTimeParameter method Adds Boolean Parameter to Collection of parameters 
        /// </summary>
        /// <param name="p_name">Name of parameter</param>
        /// <param name="p_value">Value of parameter</param>
        public void AddBooleanTimeParameter(string p_name, bool p_value)
        {
            AddParameter(p_name, p_value, SqlDbType.Bit, 1, ParameterDirection.Input);

        }
        public void AddXmlParameter(string p_name, string p_value)
        {
            AddParameter(p_name, p_value, SqlDbType.Xml, 1, ParameterDirection.Input);
        }
    }
}